﻿namespace = warlord_china_events

warlord_china_events.100 = { #Split china up into warlord states
	type = country_event
	placement = root
	duration = 3

	title = warlord_china_events.100.t
	desc = warlord_china_events.100.d
	flavor = warlord_china_events.100.f

	event_image = {
		video = "gfx/event_pictures/unspecific_armored_train.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/unspecific/armored_train"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	trigger = {
		NOT = { has_global_variable = china_shatters }
	}

	immediate = {
		set_global_variable = china_shatters
		if = {
			limit = { exists = s:STATE_HUNAN.region_state:MCH }
			create_country = {
				tag = HNA
				origin = this
				state = s:STATE_HUNAN.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:HNA = { save_scope_as = scope_HNA }
			if = {
				limit = { exists = s:STATE_WESTERN_HUBEI.region_state:MCH }
				s:STATE_WESTERN_HUBEI.region_state:MCH = { set_state_owner = c:HNA }
			}
			if = {
				limit = { exists = s:STATE_EASTERN_HUBEI.region_state:MCH }
				s:STATE_EASTERN_HUBEI.region_state:MCH = { set_state_owner = c:HNA }
			}
		}

		if = {
			limit = { exists = s:STATE_GUANGXI.region_state:MCH }
			create_country = { #Guangxi
				tag = GNG
				origin = this
				state = s:STATE_GUANGXI.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:GNG = { save_scope_as = scope_GNG }
		}

		if = {
			limit = { exists = s:STATE_SOUTHERN_ANHUI.region_state:MCH }
			create_country = { #Anhui Clique
				tag = AHU
				origin = this
				state = s:STATE_SOUTHERN_ANHUI.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:AHU = { save_scope_as = scope_AHU }
			if = {
				limit = { exists = s:STATE_NORTHERN_ANHUI.region_state:MCH }
				s:STATE_NORTHERN_ANHUI.region_state:MCH = { set_state_owner = c:AHU }
			}
			if = {
				limit = { exists = s:STATE_HENAN.region_state:MCH }
				s:STATE_HENAN.region_state:MCH = { set_state_owner = c:AHU }
			}
		}

		if = {
			limit = { exists = s:STATE_ZHILI.region_state:MCH }
			create_country = { #Zhili Clique
				tag = ZHI
				origin = this
				state = s:STATE_ZHILI.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:ZHI = { save_scope_as = scope_ZHI }
		}

		if = {
			limit = { exists = s:STATE_SOUTHERN_MANCHURIA.region_state:MCH }
			create_country = { #Fengtian Clique
				tag = MCH
				origin = this
				state = s:STATE_SOUTHERN_MANCHURIA.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:MCH = { save_scope_as = scope_MCH }
			if = {
				limit = { exists = s:STATE_NORTHERN_MANCHURIA.region_state:MCH }
				s:STATE_NORTHERN_MANCHURIA.region_state:MCH = { set_state_owner = c:MCH }
			}
			if = {
				limit = { exists = s:STATE_OUTER_MANCHURIA.region_state:MCH }
				s:STATE_OUTER_MANCHURIA.region_state:MCH = { set_state_owner = c:MCH }
			}
		}

		if = {
			limit = { exists = s:STATE_SHANXI.region_state:MCH }
			create_country = {  #Shanxi
				tag = SHN
				origin = this
				state = s:STATE_SHANXI.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:SHN = { save_scope_as = scope_SHN }
		}

		if = {
			limit = { exists = s:STATE_TIANSHAN.region_state:MCH }
			create_country = {  #Xinjiang Clique
				tag = XIN
				origin = this
				state = s:STATE_TIANSHAN.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:XIN = { save_scope_as = scope_XIN }
			if = {
				limit = { exists = s:STATE_DZUNGARIA.region_state:MCH }
				s:STATE_DZUNGARIA.region_state:MCH = { set_state_owner = c:XIN }
			}
		}

		if = {
			limit = { exists = s:STATE_YUNNAN.region_state:MCH }
			create_country = {  #Yunnan
				tag = YUN
				origin = this
				state = s:STATE_YUNNAN.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:YUN = { save_scope_as = scope_YUN }
		}

		if = {
			limit = { exists = s:STATE_GUIZHOU.region_state:MCH }
			create_country = { #Guizhou
				tag = GUI
				origin = this
				state = s:STATE_GUIZHOU.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:GUI = { save_scope_as = scope_GUI }
			if = {
				limit = { exists = s:STATE_CHONGQING.region_state:MCH }
				s:STATE_CHONGQING.region_state:MCH = { set_state_owner = c:GUI }
			}
		}

		if = {
			limit = { exists = s:STATE_GUANGDONG.region_state:MCH }
			create_country = { #Guangdong
				tag = YUE
				origin = this
				state = s:STATE_GUANGDONG.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:YUE = { save_scope_as = scope_YUE }
			if = {
				limit = { exists = s:STATE_SHAOZHOU.region_state:MCH }
				s:STATE_SHAOZHOU.region_state:MCH = { set_state_owner = c:YUE }
			}
		}

		if = {
			limit = { exists = s:STATE_SICHUAN.region_state:MCH }
			create_country = {
				tag = SIH
				origin = this
				state = s:STATE_SICHUAN.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:SIH = { save_scope_as = scope_SIH }
			if = {
				limit = { exists = s:STATE_QINGHAI.region_state:MCH }
				s:STATE_QINGHAI.region_state:MCH = { set_state_owner = c:SIH }
			}
		}

		if = {
			limit = { exists = s:STATE_SHANDONG.region_state:MCH }
			create_country = {
				tag = SHA
				origin = this
				state = s:STATE_SHANDONG.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:SHA = { save_scope_as = scope_SHA }
		}

		if = {
			limit = { exists = s:STATE_NINGXIA.region_state:MCH }
			create_country = {
				tag = XIB
				origin = this
				state = s:STATE_NINGXIA.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:XIB = { save_scope_as = scope_XIB }
			if = {
				limit = { exists = s:STATE_GANSU.region_state:MCH }
				s:STATE_GANSU.region_state:MCH = { set_state_owner = c:XIB }
			}
			if = {
				limit = { exists = s:STATE_ALXA.region_state:MCH }
				s:STATE_ALXA.region_state:MCH = { set_state_owner = c:XIB }
			}
		}

		if = {
			limit = { exists = s:STATE_ULAANBAATAR.region_state:MCH }
			create_country = {
				tag = MGL
				origin = this
				state = s:STATE_ULAANBAATAR.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
				}
			}
			c:MGL = { save_scope_as = scope_MGL }
			if = {
				limit = { exists = s:STATE_KHOVSGOL.region_state:MCH }
				s:STATE_KHOVSGOL.region_state:MCH = { set_state_owner = c:MGL }
			}
		}

		if = {
			limit = { exists = s:STATE_TUVA.region_state:MCH }
			create_country = {
				tag = TUV
				origin = this
				state = s:STATE_TUVA.region_state:MCH

				on_created = {
					warlord_setup_effect = yes
					set_variable = warlord_state
				}
			}
			c:TUV = { save_scope_as = scope_TUV }
		}

		every_subject_or_below = {
			make_independent = yes
		}

		random_country = {
			limit = {
				has_variable = warlord_state
				NOR = {
					has_variable = var_warlord_two
					has_variable = var_warlord_three
					has_variable = var_warlord_four 
				}
			}
			save_scope_as = scope_random_warlord_one
			set_variable = var_warlord_one
		}

		random_country = {
			limit = {
				has_variable = warlord_state
				NOR = {
					has_variable = var_warlord_one
					has_variable = var_warlord_three
					has_variable = var_warlord_four
				}
			}
			save_scope_as = scope_random_warlord_two
			set_variable = var_warlord_two
		}

		random_country = {
			limit = {
				has_variable = warlord_state
				NOR = {
					has_variable = var_warlord_one
					has_variable = var_warlord_two
					has_variable = var_warlord_four
				}
			}
			save_scope_as = scope_random_warlord_three
			set_variable = var_warlord_three
		}

		random_country = {
			limit = {
				has_variable = warlord_state
				NOR = {
					has_variable = var_warlord_one
					has_variable = var_warlord_two
					has_variable = var_warlord_three
				}
			}
			save_scope_as = scope_random_warlord_four
			set_variable = var_warlord_four
		}
	}

	option = {
		name = warlord_china_events.100.ab
		trigger = {
			exists = scope:scope_random_warlord_one
			is_player = yes
		}
		play_as = scope:scope_random_warlord_one
	}

	option = {
		name = warlord_china_events.100.b
		trigger = {
			exists = scope:scope_random_warlord_two
			is_player = yes
		}
		play_as = scope:scope_random_warlord_two
	}

	option = {
		name = warlord_china_events.100.c
		trigger = {
			exists = scope:scope_random_warlord_three
			is_player = yes
		}
		play_as = scope:scope_random_warlord_three
	}

	option = {
		name = warlord_china_events.100.aa
		trigger = {
			exists = scope:scope_random_warlord_four
			is_player = yes
		}
		play_as = scope:scope_random_warlord_four
	}

	option = {
		default_option = yes
		name = warlord_china_events.100.a
	}
}



warlord_china_events.110 = { #Prisoner Killing
	type = country_event
	placement = root
	duration = 3

	title = warlord_china_events.110.t
	desc = warlord_china_events.110.d
	flavor = warlord_china_events.110.f

	event_image = {
		video = "gfx/event_pictures/asia_farmers_market.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/farmers_market"

	icon = "gfx/interface/icons/event_icons/event_skull.dds"

	trigger = {
		any_scope_character = {
			is_ruler = yes

			has_trait = cruel

		}
		has_government_type = gov_warlord_state
	}

	immediate = {
		random_scope_character = {
			limit = {
				is_ruler = yes

				has_trait = cruel
			}
			save_scope_as = prisoner_killing_warlord
		}

	}

	option = {
		default_option = yes
		name = warlord_china_events.110.a
		capital = {
			add_radicals = {
				value = 0.5
			}
		}

	}

	option = {
		default_option = yes
		name = warlord_china_events.110.b
		add_modifier = {
			name = modifier_prisoner_murder_covered_up
			months = normal_modifier_time
		}

	}
}




# Yan Xishan Thought
warlord_china_events.301 = {
	type = country_event
	placement = root
	duration = 3

	title = warlord_china_events.301.t
	desc = warlord_china_events.301.d
	flavor = warlord_china_events.301.f



	gui_window = event_window_1char_tabloid
	left_icon = scope:yan_xishan_thinker

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/misc/1Character_Banner"

	icon = "gfx/interface/icons/event_icons/event_portrait.dds"

	trigger = {
		has_government_type = gov_warlord_state
		has_law = law_type:law_autocracy
		has_technology_researched = mass_propaganda
		NOT = {
			ruler = {
				interest_group = {
					OR = {
						has_modifier = yan_xishan_thought_mod
						has_modifier = failed_yan_xishan_thought_mod
					}
				}
			}
		}
		NOT = {
			has_modifier = warlord_legitimacy
		}
	}
	immediate = {
		ruler = {
			save_scope_as = yan_xishan_thinker
			interest_group = {
				save_scope_as = yan_xishan_ig
			}
		}
	}
	option = {
		name = warlord_china_events.301.a
		default_option = yes
		random_list = {
			50 = {
				modifier = {
					if = {
						limit = {
							any_scope_state = {
								is_production_method_active = {
									building_type = building_university
									production_method = pm_philosophy_department
								}
							}
						}
					}
					add = 25
				}
				modifier = {
					if = {
						limit = {
							government_legitimacy = 75
						}
					}
					add = 25
				}
				root = {
					add_modifier = {
						name = yan_xishan_thought_mod
					}
				}
			}
			50 = {
				modifier = {
					if = {
						limit = {
							government_legitimacy = 50
						}
					}
					add = 25
				}
				root = {
					add_modifier = {
						name = failed_yan_xishan_thought_mod
						months = normal_modifier_time
					}
				}
			}
		}
	}
	option = {
		name = warlord_china_events.301.b
		add_modifier = {
			name = warlord_legitimacy
			months = normal_modifier_time
		}
	}
}
